<template>
	<view>
		<view class="uni-section" :style="{height:getHeight,backgroundColor:backgroundColor}">
			<view class="status_bar" :style="{'height':statusBarHeight+'px'}">
			</view>
			<view :style="{marginTop:getTop}">
				<slot name="navbar" />
			</view>
		</view>
		<view :style="{height:getHeight}"></view>
	</view>

</template>

<script>
	/**
	 * Section 标题栏
	 * @description 标题栏
	 * @property {String} type = [line|circle] 标题装饰类型
	 * 	@value line 竖线
	 * 	@value circle 圆形
	 * @property {String} title 主标题
	 * @property {String} subTitle 副标题
	 */

	export default {

		name: 'UniSection',
		emits: ['click'],
		props: {
			backgroundColor: {
				type: String,
				default: "#fff"
			}
		},
		data() {
			return {
				menuButtonInfo: null, //胶囊信息
				statusBarHeight: 0, //状态栏高度
				musicheadHeight: 0, //导航栏高度

			}
		},
		watch: {
			title(newVal) {
				if (uni.report && newVal !== '') {
					uni.report('title', newVal)
				}
			}
		},
		computed: {
			getHeight() {
				return (this.statusBarHeight + this.musicheadHeight) * 2 + 'rpx';
			},
			getTop() {
				return (this.menuButtonInfo.top - this.statusBarHeight) * 2 + 'rpx';
			}
		},
		created() {
			this.init();
		},
		mounted() {},
		methods: {
			init() {
				const {
					statusBarHeight, //状态栏高度
				} = uni.getSystemInfoSync(); //获取机型配置
				this.statusBarHeight = statusBarHeight;

				const {
					width,
					height,
					top
				} = uni.getMenuButtonBoundingClientRect(); //获取胶囊信息
				this.menuButtonInfo = {
					width,
					height,
					top
				} //胶囊信息
				const topDistance = this.menuButtonInfo.top - this.statusBarHeight; //胶囊里状态栏的高度
				this.musicheadHeight = this.menuButtonInfo.height + topDistance * 2; //导航栏高度
			}
		}
	}
</script>
<style lang="scss" scoped>
	$uni-primary: #2979ff !default;

	.uni-section {
		width: 750rpx !important;
		background-color: #fff;
		position: fixed;
		z-index: 100;
		// overflow: hidden;
	}

	.uni-section-header {
		position: relative;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
		// height: 50px;
		font-weight: normal;
		height: var(--status-bar-height);
	}

	.uni-section__head {
		flex-direction: row;
		justify-content: center;
		align-items: center;
		margin-right: 10px;
	}

	.line {
		height: 12px;
		background-color: $uni-primary;
		border-radius: 10px;
		width: 4px;
	}

	.circle {
		width: 8px;
		height: 8px;
		border-top-right-radius: 50px;
		border-top-left-radius: 50px;
		border-bottom-left-radius: 50px;
		border-bottom-right-radius: 50px;
		background-color: $uni-primary;
	}

	.uni-section__content {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		flex: 1;
		color: #333;
		height: 96rpx;
	}

	.uni-section__content-title {
		font-size: 14px;
		color: $uni-primary;
	}

	.distraction {
		flex-direction: row;
		align-items: center;
	}

	.uni-section__content-sub {
		font-size: 12px;
		color: #999;
		line-height: 16px;
		margin-top: 2px;
	}

	.status_bar {
		height: var(--status-bar-height);
		width: 100%;
	}

	.musicheadWEIXIN {
		width: 100%;
		padding: 0;
		margin: 0;
	}
</style>
